package router

import (
	jwt "gitee.com/sansaniot/ssiot-core/httpmvc/jwtauth"
	"github.com/gin-gonic/gin"
	"ssadmin/common/middleware/handler"
)

func init() {
	AuthRouters = append(AuthRouters, loginRouter)
}

func loginRouter(r *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
	user := r.Group("/api/user").Use(authMiddleware.MiddlewareFuncWithOutValidate())
	{
		user.POST("/logout", handler.Logout)
		user.POST("/token/refresh", authMiddleware.RefreshHandler)
	}

	login := r.Group("/api/auth")
	{
		login.POST("/login", authMiddleware.LoginHandler)
		login.GET("/check", authMiddleware.MiddlewareFunc(), handler.CheckLogin)
	}
}
